<?php
/*
 * NetfilterEyes - 2008 - Anouar Belkacem
 * This code is a modified copy of the FirewallEyes project source code
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

// authentification check
authenticationCheck();

// GET INPUT
$type=stripslashes($_GET["type"]);
$p1=stripslashes($_GET["p1"]);

$tool=stripslashes($_GET["tool"]);

$toolsArray=$tools[$type];


$maxWidth=0;
for($i=0; $i<count($logFields); $i++) {
	$maxWidth+=$logFields[$i][2];
}
?>
<div align="left" style="padding-left:18px">
<table border="0" cellpadding="0" cellspacing="0" width="<?=$maxWidth?>">
<tr>
	<td class="toolBox">
		<form method="GET" action="info.php">
			<br/>
			<b>Informations on </b>
			<input type="text" name="p1" class="inputText" maxlength="100" value="<?=htmlentities(stripslashes($p1))?>">
			<input type="hidden" name="type" value="<?=htmlentities(stripslashes($type))?>">
			<br/><br/>&nbsp;
			<?php
			foreach($toolsArray as $toolName=>$toolInfos) {
				?>
				<input class="toolbutton" type="submit" name="tool" value="<?=htmlentities($toolName)?>">&nbsp;&nbsp;
				<?php
			}
			?>
		</form>
	</td>
</tr>
</table>
<?php
flush();
if($tool) {
	if($toolsArray[$tool]["type"]=="command") {
		$myCommand=$toolsArray[$tool]["value"];
		$myparam=$p1;
		if($toolsArray[$tool]["precompute"]=="extractdomain") {
			if (preg_match("/\d+\.\d+\.\d+\.\d+/", $p1)) { // it's an ip address
				$myparam=$p1;
			} else {
				$myparam=substr(strstr($p1,"."),1); // remove first part of canonical name
			}
		}
		$myCommand=str_replace("%p1%",$myparam,$myCommand);
	}
	if($toolsArray[$tool]["type"]=="url") {
		$myCommand=$toolsArray[$tool]["value"];
		$myCommand=str_replace("%p1%",urlencode($p1),$myCommand);

	}
?>
<br/>
<table border="0" cellpadding="0" cellspacing="0" width="<?=$maxWidth?>">
<tr>
	<td class="toolCommandBoxHeader">
	 <?php
		if($toolsArray[$tool]["type"]=="url") {
	 	?>
	 		<a style="color: #FFFFFF" href="<?=$myCommand?>" target="q"><?=$myCommand?></a>
	 	<?php
		} else {
			echo($myCommand);
		}
	 
		?>
		
	</td>
</tr>
</table>
<?php
flush();
?>
<table border="0" cellpadding="0" cellspacing="0" width="<?=$maxWidth?>">
<tr>
	<td class="toolCommandBox">
		<?php
	if($toolsArray[$tool]["type"]=="command") {
		echo("<pre>");
		passthru(escapeshellcmd($myCommand));
		echo("</pre>");
	}
	if($toolsArray[$tool]["type"]=="url") {
		?>
		<iframe name="window_recherche_affaire_resultat" src="<?=$myCommand?>" width="<?=$maxWidth-5?>" height="350"  FRAMEBORDER=0>
		Your browser doesn't support iframe, unable to get url.
		</iframe>
		<?php
	}
		?>
	</td>
</tr>
</table>
<?php
}
?>
</div>
